package d0320;

import java.util.Scanner;

public class Test {

        private static Scanner sc;
        public static void main(String[] args) {
            int[] arr=new int[10];
            sc = new Scanner(System.in);
            System.out.println("请输入10个数字:");
            for(int i=0;i<10;i++)
            {
                arr[i]=sc.nextInt();
            }



            bubbleSort(arr);
            System.out.println("排序后是:");
            arrayPrint(arr);
        }

        public static void bubbleSort(int[] arr)
        {
            for(int x=0;x<arr.length-1;x++)
            {
                for(int y=0;y<arr.length-1-x;y++)
                {
                    if(arr[y]>arr[y+1])
                    {
                        int temp=arr[y];
                        arr[y]=arr[y+1];
                        arr[y+1]=temp;

                    }
                }
            }
        }

        public static void arrayPrint(int[] arr)
        {
            System.out.print("[");
            for(int i=0;i<arr.length;i++)
            {
                if(i==arr.length-1){
                    System.out.print(arr[i]);
                }
                else
                    System.out.print(arr[i]+", ");
            }
            System.out.println("]");

        }



}
